<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="__ACTION__">
      <input name="pid" type="hidden" value="{$Think.get.pid}">
      <input name="cid" type="hidden" value="{$Think.get.cid}">
      选择类别：
      <select name="selectId" id="selectId">
        <option value="0">请选择分类</option>
        <volist name="list" id="vo">
          <option value="{$vo.id}" >{$vo.name} </option>
        </volist>
      </select>
    </form>
    <div class="content-menu" style="position: absolute; right: 30px;top: 5px;"> <a href="javascript:history.go(-1);" class="add fb"><em>返回</em></a> </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form id="listForm" action="__URL__/updateSort" method="POST">
    <div class="table-list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <th align="center" width="50">排序</th>
            <th align="center" width="50">序号</th>
            <th align="center" width="50">ID</th>
            <th align="left">名称
            <notempty name="Think.get.pName"><span class="red">({$Think.get.pName})</span></notempty>
            </th>
            <th align="center" width="80">编号</th>
            <th align="center" width="80">级别</th>
            <th align="center"  width="80">状态</th>
            <th align="center" width="180">管理操作</th>
          </tr>
        </thead>
        <tbody id="list">
          <volist name="list" id="vo">
            <tr id="list_{$vo.id}">
              <td align="center">
              	<input name='sortArr[]' type='text' size="4" value='{$vo.sort}' class='input-text-c'>
              	 <input name='idArr[]' type="hidden" value='{$vo.id}'>
              </td>
              <td align="center">{$i}</td>
              <td align="center">{$vo.id}</td>
              <td align="left">{$vo.name}</td>
              <td align="center">{$vo.bh}</td>
              <td align="center">{$vo.levelName}</td>
              <td align="center"><a href="javascript:changeStatus({$vo.id});" id="status-{$vo.id}" name="{$vo.status}" title="" class="status" >{$vo.statusName}</a></td>
              <td align="center"><a href="__ACTION__/pid/{$vo.id}/pName/{$vo.name}" class="showCityList">【查看城市列表】</a> <a href="__ACTION__/pid/{$Think.get.pid}/cid/{$vo.id}/pName/{$vo.name}" class="showAreaList">【查看区域列表】</a></td>
            </tr>
          </volist>
        </tbody>
      </table>
      <div class="btn">
        <div id="pages">{$page}</div>
        <input name="submit" type="submit" class="button" value="更新排序" >
      </div>
    </div>
  </form>
</div>
</body></html><script type="text/javascript">
$(document).ready(function(){
	//赋予状态颜色
	$(".status").each(function(i, val) {
        var status = $(this).attr('name');
		if(status==1){
			$(this).addClass('blue');
		}else{
			$(this).addClass('red');
		}
    });
	
	//隐藏区域列表按钮
	$(".showAreaList").hide();
	$(".content-menu").hide();
	if( "{$Think.get.pid}"!=0 ){
		$(".showAreaList").show();
		$(".showCityList").hide();
		$(".content-menu").show();
	}
	if( "{$Think.get.pid}"!=0 && "{$Think.get.cid}"!=0 ){
		$(".showAreaList").hide();
		$(".showCityList").hide();
		$(".content-menu").show();
	}
	
    $('#listForm').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		return true;
	}
	
	var origin = $.artDialog.open.origin;
    function complete(data){
		msg(data.info,data.status);
		if(data.status)  setTimeout(function(){origin.location.reload();},1000);
		closeWin(1500);
    }
	
	$("#selectId").change(function(){
		var  pid = $("input[name='pid']").val();
		var  cid = $("input[name='cid']").val();
		var selectId = $(this).val();
		if(pid==0 || pid==''){
			$("input[name='pid']").val(selectId);
		}else{
			$("input[name='cid']").val(selectId);
		}
		
		$("#searchForm").submit();
	})
	
})

function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("__URL__/changeStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('隐藏');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('显示');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}				  
	});
}

</script>